package com.wiloon.java8x.basic.type;

import org.apache.commons.codec.binary.Hex;

public class DataType {
    public static void main(String[] args) {
        String s = "35";
        System.out.println("source string:" + s);
        byte[] b = s.getBytes();
        for (byte bTmp : b) {
            System.out.println("byte:" + bTmp);
            System.out.println("unsign int:" + convertByteToUnsignInteger(bTmp));
            System.out.println("binary str:" + Integer.toBinaryString(convertByteToUnsignInteger(bTmp)));

        }

        String newHex = Hex.encodeHexString(b);
        System.out.println("hex:" + newHex);

        System.out.println("---");

        System.out.println(String.format("%08d", 123));
        System.out.println(String.format("%08d", Long.parseLong("123")));
        System.out.println(String.format("%9s", "123"));

        System.out.println("binary str:" + Integer.toBinaryString(convertByteToUnsignInteger((byte) 1)));
    }

    public static int convertByteToUnsignInteger(byte b) {
        int i = 0;
        i = b & 0xff;
        return i;
    }

    private void test() {
        System.out.println(Boolean.parseBoolean("true"));
        System.out.println(Boolean.parseBoolean("True"));
        System.out.println(Boolean.parseBoolean("TRUE"));
        System.out.println(Boolean.parseBoolean("truE"));

        System.setProperty("socket.handler.response.equipment","false");
        System.setProperty("socket.response","false");
    }
}
